<extend name="Index:base" />
<block name="content">
    <div class="main-content">
        <div class="breadcrumbs" id="breadcrumbs">
            <!-- 面包屑导航 -->
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home home-icon"></i>
                    <a href="{:U('Admin/Index/index')}">首页</a>
                </li>
                <li>
                    <a href="{:U('Admin/Grouplist/index')}">{$page['title']['prev']}</a>
                </li>
                <li class="active">
                    {$page['title']['current']}
                </li>
            </ul>
        </div>
        <div class="page-content">
            <!-- 页面导航 -->
            <div class="page-header">
                <h1>
                    {$page['title']['current']}
                    <a class="btn btn-info btn-sm pull-right" href="{:U('Admin/Grouplist/index')}">
                        <i class="icon-reply icon-only"></i>
                    </a>
                </h1>
            </div>

            <!-- 添加按钮 -->
            <div class="row" style="padding:0px;height:auto;overflow:hidden;margin-bottom:10px;">
                <div class="col-xs-12 col-sm-8">
                    <a class="btn btn-primary pull-left" style="padding:1px 10px;" href="{:U('Admin/Grouplist/addMem',array('id'=>$_GET['id']))}">
                        <i class="icon-plus-sign bigger-125"></i>
                        添加成员
                    </a>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="table-responsive">
                        <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>UID</th>
                                    <th class="width-15">用户名</th>
                                    <th class="width-25">所属组</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <!--一行的开始-->
                            <!--遍历查询到的数据-->
                            <tbody>
                                <volist name="data" id="vo">
                                <tr>
                                    <td>
                                        {$vo['uid']}
                                    </td>
                                    <td>{$vo['uname']}</td>
                                    <td>{$gtitle}</td>
                                    <td>
                                        <div class="visible-md visible-lg visible-sm visible-xs action-buttons">
                                            <a name="del_{$vo['uid']}_{$vo['group_id']}" class="red" data-toggle="modal" href="#deleteModal">
                                                <i class="icon-trash bigger-130"></i>
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                <!--遍历结束-->
                                </volist>

                                <!--一行的结束--> 
                            </tbody>
                        </table>
                    </div>
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.page-content -->
    </div><!-- /.main-content -->
    <!-- 中间部分结束 -->
    
    <!-- 删除按钮弹出层 -->
    <div class="modal modal-small fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width:300px;">
            <div class="modal-content" style="top:160px;left:80%;">
                <div class="modal-header" style="height:40px;padding:5px 10px;line-height:30px;">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <p class="bigger-120" id="myModalLabel">删除数据</p>
                </div>
                <div class="modal-body" style="height:70px;padding:5px 10px;line-height:60px;">
                    <p class="text-danger bigger-150">确定删除数据！</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-sm btn-danger" id="delete-data">删除</button>
                    <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div id="success-info" class="alert alert-success fade in col-xs-4 hide" style="position:fixed;top:20px;left:35%;z-index:1000;">
        <button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
        <strong></strong>
    </div>
    <div id="error-info" class="alert alert-danger fade in col-xs-4 hide" style="position:fixed;top:20px;left:35%;z-index:1000;">
        <button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
        <strong></strong>
    </div>
    <!-- 删除按钮弹出层结束 -->
</block>
<block name="privatejs">
    <script type="text/javascript">
        jQuery(function($) {
            //设置当前页面的菜单高亮显示 开始
            var nownav = "#sidebar a[href*=Grouplist]";
            var parentattr = $(nownav).parent().parent().attr("class");
            $(nownav).parent().addClass('active');
            if (parentattr == 'submenu') {
                $(nownav).parent().parent().parent().addClass('active open');
            };
            //设置当前页面的菜单高亮显示 结束
            
            var delid;
            var gid;
            $('a[name^=del]').on('click',function(){
                var ids = $(this).attr('name').split('_');
                delid = ids[1];
                gid = ids[2];
            });
           
            $('#delete-data').on('click',function(){
                $.ajax({
                   url:"__APP__/Admin/Grouplist/deleteMem",
                   type:"post",
                   data:{uid:delid,group_id:gid},
                   success:function(data){
                        if (data == 1) {
                            warningInfo("#success-info","删除成功！");
                            location.href='';
                        }else if(data == 2){
                            warningInfo("#error-info","没有删除权限！");
                        }else{
                            warningInfo("#error-info","删除失败！");
                        }
                        $('#deleteModal').modal('hide');
                   }
                });
            });
           
            //信息提示函数
            function warningInfo(id,info){
               $(id).removeClass('hide');
               $(id).fadeOut(0);
               $(id).children().eq(1).html(info);
               $(id).fadeToggle(0).delay(1000).fadeToggle(1000);
            }
        });
    </script>
</block>